package net.zio.kamenriderzioaddon.mixin;

import net.minecraft.world.entity.player.Player;
import net.zio.kamenriderzioaddon.enums.HenshinState;
import net.zio.kamenriderzioaddon.ridersystem.data.PlayerDataManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
 * Mixin class for inventory menu slot functionality.
 *
 * @author QianYunYi
 */
@Mixin(targets = "net/minecraft/world/inventory/InventoryMenu$1")
public abstract class InventoryMenuSlotMixin {

    @Inject(
            method = "mayPickup(Lnet/minecraft/world/entity/player/Player;)Z",
            at = @At("HEAD"),
            cancellable = true
    )
    private void preventArmorPickup(Player player, CallbackInfoReturnable<Boolean> callback) {
        // 获取玩家的持久化数据
        PlayerDataManager playerData = PlayerDataManager.get(player);
        System.out.println("玩家当前状态"+playerData.getCurrentState());

        // 阻止在变身状态下拾取盔甲
        if (playerData.getCurrentState().equals(HenshinState.ACTIVE)||
                playerData.getCurrentState().equals(HenshinState.ACTIVE_AWAKENING)) {
            callback.setReturnValue(false);
        }
    }
}